<?php defined('_JEXEC') or die('Restricted access'); ?>
<?php

// Initialize variables
$db		=& JFactory::getDBO();
$user	=& JFactory::getUser();
$config	=& JFactory::getConfig();
$now	=& JFactory::getDate();

//Ordering allowed ?
$ordering = ($this->lists['order'] == 'ordering');

$config 		= &JComponentHelper::getParams('com_yos_news_crawler');
$data_type 		= $config->get('data_type');

JHTML::_('behavior.tooltip');
?>
<form action="index.php?option=<?php echo $option; ?>" method="post" name="adminForm">
<table>
<tr>
	<td align="left" width="100%">
		<?php echo JText::_( 'Filter' ); ?>:
		<input type="text" name="search" id="search" value="<?php echo $this->lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />
		<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
		<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_sectionid').value='-1';this.form.getElementById('catid').value='0';this.form.getElementById('filter_state').value='';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
	</td>
</tr>
</table>
<table class="adminlist">
	<thead>
		<tr>
			<th width="10">
				<?php echo JText::_( 'Num' ); ?>
			</th>
			<th width="10" class="title">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->rows); ?>);" />
			</th>
			<th class="title" width="500">
				<?php echo JHTML::_('grid.sort',   'Link', 'link', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
			</th>
			<th width="1%" nowrap="nowrap">
				<?php echo JHTML::_('grid.sort', 'Category type', 'category', @$this->lists['order_Dir'], @$this->lists['order']); ?>
			</th>	
			<th width="100">
				<?php echo JHTML::_('grid.sort', 'Title', 'title', @$this->lists['order_Dir'], @$this->lists['order']);?>
			</th>
			<th width="300">
				<?php echo JHTML::_('grid.sort', 'Description', 'description', @$this->lists['order_Dir'], @$this->lists['order']);?>
			</th>
			<th width="1%" nowrap="nowrap">
				<?php echo JHTML::_('grid.sort', 'URL', 'url', @$this->lists['order_Dir'], @$this->lists['order']);?>
			</th>				
			<th width="1%" nowrap="nowrap">
				<?php echo JText::_('Back-up'); ?>
			</th>
			<th width="1%" nowrap="nowrap">
				<?php echo JHTML::_('grid.sort',   'ID', 'ync.id', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
			</th>
		</tr>
	</thead>
	<tfoot>
		<tr>
			<?php if ($data_type == 'joomla') {?>
			<td colspan="12">
			<?php }else {?>
			<td colspan="11">
			<?php }?>
				<?php echo $this->pageNav->getListFooter(); ?>
			</td>
		</tr>
	</tfoot>
	<tbody>
	<?php
	$k = 0;
	$nullDate = $db->getNullDate();
	
	for ($i=0, $n=count($this->rows); $i < $n; $i++) {
		$row = $this->rows[$i];
		
		$link 		= JRoute::_( 'index.php?option='.$option.'&task=link.edit&returndotask=linkmanager&cid[]='. $row->id );	
		$backup		=	JRoute::_('index.php?option=com_yos_news_crawler&task=link.backup&cid[]='.$row->id);
		?>
		<tr class="<?php echo "row$k"; ?>">
			<td>
				<?php echo $this->pageNav->getRowOffset( $i ); ?>
			</td>
			<td>
				<input type="checkbox" id="cb<?php echo $i; ?>" name="cid[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" />
			</td>
			<td>
				<span class="editlinktip hasTip" title="<?php echo JText::_( 'Edit Link' );?>::<?php echo $row->link; ?>">
				<a href="<?php echo $link; ?>">
					<?php echo $row->link; ?></a> </span>						
			</td>
			<td align="center">
				<?php echo $row->category ? 'Rss' : 'HTTP'; ?>
			</td>
			<td align="center">
				<?php echo JText::_($row->title); ?>
			</td>
			<td align="center">
				<?php echo JText::_($row->description); ?>
			</td>
			<td align="center">
				<span class="editlinktip hasTip" title="<?php echo JText::_( 'Go to' );?>::<?php echo $row->url; ?>">
				<a href="<?php echo $row->url; ?>" target="_blank"><img src="components/com_yos_news_crawler/assets/images/url.png" /></a>
				</span>
			</td>
			<td align="center">
				<a href="<?php echo $backup; ?>"><img src="components/com_yos_news_crawler/assets/images/download_f2.png" /></a>
			</td>
			<td align="center">
				<?php echo $row->id; ?>
			</td>
		</tr>
		<?php
		$k = 1 - $k;
	}
	?>
	</tbody>
</table>
<input type="hidden" name="option" value="<?php echo $this->option; ?>" />
<input type="hidden" name="task" value="linkmanager" />
<input type="hidden" name="dotask" value="list" />
<input type="hidden" name="returndotask" value="linkmanager" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
